stage.set_background("concert")
sprite = codesters.Sprite("person1")
sprite.set_speed(3)
sprite.move_down(100)
sprite.flip_up_down()
sprite.move_right(150)
sprite.move_left(200)
sprite.flip_up_down()
sprite.turn_left(360)
stage.wait(0.75)
sprite.flip_right_left()
t = codesters.Teacher()
try:
param = t.find_function('flip_right_left')
tval1 = len(param)
except:
tval1 = "DNE"
try:
param = t.find_function('wait')
tval2 = len(param)
except:
tval2 = "DNE"
try:
param = t.find_function('wait')
lst = [item for item in param if '2' in item[1]]
tval3 = len(lst)
except:
tval3 = "DNE"
try:
wt_param = t.find_function('wait')
fl_param = t.find_function('flip_right_left')
wt_list = [item for item in [item[0] for item in wt_param]]
fl_list = [item for item in [item[0] for item in fl_param]]
# this pre-makes the list so we can use slices to put
# the line numbers into it
total_list = [None]*(len(wt_list)+len(fl_list))
total_list[1::2] = fl_list
total_list[::2] = wt_list
sorted_total = sorted(total_list, key = int)
except:
tval4 = "DNE"
sorted_total = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 6, "Great Job!")
t1.add_failure(tval1 == 1, "Did you add more flip commands?")
t1.add_creative(tval1 > 6, "That's a lot of flips!")
t1.add_failure(tval1 == "DNE", "Did you delete the sprite?")
t2 = TestObjective()
t2.add_success(tval2 == 6, "Great job!")
t2.add_failure(tval2 == 1, "Did you add more wait commands?")
t2.add_failure(tval2 == 0, "Did you delete all the wait commands?")
t2.add_failure(tval3 > 0 and tval2 > 5, "Did you change the integer in each wait command?")
t4 = TestObjective()
t4.add_success(sorted_total == total_list and tval2 > 5, "Great job!")
t4.add_failure(sorted_total != total_list and tval2 > 5, "Are all your wait and flip commands in the right order?")
t4.add_failure(sorted_total == total_list and tval2 < 5, "Did you add more wait commands?")
tester = TestManager()
tester.add_test_list([t1, t2, t4])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)